package com.jarchie.newfuncdemo;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * 电子签名，手势输入Demo
 */
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    private SignView mSignView;
    private ImageView mDisplayImg;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mSignView = (SignView) findViewById(R.id.main_signview);
        TextView clearBtn = (TextView) findViewById(R.id.btn_clear);
        TextView saveBtn = (TextView) findViewById(R.id.btn_save);
        mDisplayImg = (ImageView) findViewById(R.id.mDisplayImg);
        clearBtn.setOnClickListener(this);
        saveBtn.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.btn_clear:
                mSignView.clearPath();
                break;
            case R.id.btn_save:
                mDisplayImg.setImageBitmap(mSignView.getImage());
                break;
        }
    }
}
